#define _CRT_SECURE_NO_WARNINGS 1

#include"Seqlist.h"



void SL_init(SL* ps)
{
	assert(ps);
	ps->a = NULL;
	ps->size = 0;
	ps->capacity = 0;
}

void SL_pushback(SL* ps,SLDataType x)
{
	assert(ps);
	if (ps->size == ps->capacity)
	{
		//int newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;
		int newCapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;
		SLDataType* temp = (SLDataType*)realloc(ps->a,newCapacity*sizeof(SLDataType));
		if (temp == NULL)
		{
			perror("realloc fail:");
			exit(1);
		}
		ps->a = temp;
		ps->capacity = newCapacity;
	}
	ps->a[ps->size] = x;
	ps->size++;
}

